"use strict";
var client = require("scp2");
var os = require("os");

// var random = Math.random()
// 具体文件拼写
const _Symbol = os.type() === "Darwin" || os.type() === "Linux" ? "/" : "\\"; // 如果是mac 用 /  反之 \\
const dirUrl = "H:\\project\\hxsapp-fe3\\dist";

var scpConfig = {
    "host": "121.41.83.91",
    "username": "bravo",
    "password": "E5@20240798076YwUh",
    "port": "48022",
    "path": "/apps/data/work/html/hxswap.hxsapp.com" + _Symbol + process.argv[2]
};

console.log(
 "正在上传您的打包文件到测试环境：" +
  scpConfig.host +
  ":" +
  scpConfig.port +
  " ，请稍后..."
);
console.log("上传中...");
console.log(process.argv[2], dirUrl, os.type());

const pushUrl = dirUrl + _Symbol + process.argv[2];

console.log("上传路径是: ", pushUrl);

client.scp(pushUrl, scpConfig, function (err) {
 if (!err) {
  console.log("\n");
  console.log(
   "========scp2工具上传完毕=============\n远端服务地址：" +
    scpConfig.host +
    ":" +
    scpConfig.port +
    "\n远端上传文件路径：" +
    scpConfig.path +
    "\n \n"
  );
 } else {
  console.log("err", err);
 }
});
